{template 'header'}

<body>
<div class="x-body">
    <form class="layui-form">
        <input type="hidden" name="id" value="{$father['id']}">
        <div class="layui-form-item">
            <label for="name" class="layui-form-label">
                <span class="x-red">*</span>分类名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="name" name="name" required="" lay-verify="name"
                       autocomplete="off" class="layui-input" value="{$father['name']}">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>必填
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">上级分类</label>
            <div class="layui-input-block">
                <select name="pid" lay-verify="required" disabled>
                    <option value="0">|--顶级分类</option>
                    {loop $list $item}
                    <option value="{$item['id']}" {if $item['id']==$father['id']}selected{/if}>|{php echo str_repeat('--',$item['lv'])}{$item['name']}</option>
                    {/loop}
                </select>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="summary" placeholder="请输入备注信息" class="layui-textarea">{$father['summary']}</textarea>
            </div>
        </div>
        <!--<div class="layui-form-item">-->
            <!--<label class="layui-form-label">是否开启</label>-->
            <!--<div class="layui-input-block">-->
                <!--<input type="radio" name="isopen" value="1" title="开启" {if $father['isopen']}checked{/if}>-->
                <!--<input type="radio" name="isopen" value="0" title="关闭" {if !$father['isopen']}checked{/if}>-->
            <!--</div>-->
        <!--</div>-->
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button class="layui-btn" lay-filter="add" lay-submit="">
                保存
            </button>
        </div>
    </form>
</div>
<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer;

        //自定义验证规则
        form.verify({
            name: function (value) {
                if (value.length < 2) {
                    return '分类名称至少得2个字符啊';
                }
            }
        });

        //监听提交
        form.on('submit(add)', function (data) {
            console.log(data);
            //发异步，把数据提交给php
            var url = '{php echo $this->createWebUrl("task_cate",array("op"=>"edit"))}'
            $.post(url, data.field, function (ret) {
                if (ret.code) {
                    layer.msg(ret.msg, {
                        icon: 6, end: function () {
                            //关闭当前frame
                            x_admin_close();
                            // 可以对父窗口进行刷新
                            x_admin_father_reload();
                        }
                    });
                } else {
                    layer.msg(ret.msg, {icon: 0});
                }
            }, 'json')
            return false;
        });


    });
</script>
<script>var _hmt = _hmt || [];
(function () {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>

</html>